#include <iostream>

using namespace std;

int main_0016(void)
{
    int days[] = {
        31,
        28,
        31,
        30,
        31,
        30,
        31,
        31,
        30,
        31,
        30,
        31
    };

    int year, month;

    cin >> year >> month;

    if (year % 4 == 0 && ((year % 100 != 0) || (year % 400 == 0))) {
        days[1] += 1;
    }

    cout << days[month - 1];

    return 0;
}
